#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2023/11/2 19:17
# @Author  : 作者名
# @Site    :
from tornado import web, ioloop
from tornado.options import define, options, parse_config_file

# python 命令行传递参数.py  --port=9002
# 定义key
define("port", default=9001, help="port to listen", type=int)  # 需要一个变量接收参数
define("debug", default=True, help="set debug mode", type=bool)
parse_config_file('server.conf')


class IndexHandler(web.RequestHandler):
    async def get(self):
        self.write('tornado!!hkjh99')


class IndexHandler1(web.RequestHandler):
    def get(self):
        self.write('sleep   tornado!!9kjh99')


if __name__ == '__main__':
    app = web.Application([('/v', IndexHandler), ('/v1', IndexHandler1)], debug=options.debug)  # 创建APP对象,设置路由
    app.listen(options.port)  # 监听端口
    ioloop.IOLoop.current().start()  # 开始事件循环
